<? 
	if(isset($_POST['btnupdaterows']))
	{
		require("required/dbconnect.php");
		$rows=$_POST['total_rows'];
		$update=mysql_query("update os_setting set custserv_rows=$rows");
		
		header("Location:custserv.php");
	
	}
	
	$title="User List"; 
	$pageid="4";
	$accessid=",a10,";
	
	require("required/dbconnect.php"); 
	require("required/function.php");	
	require("required/header.php");
	

	
	
	
	$get_news=mysql_query("select * from os_custserv_cat order by row asc, order_id asc");
	
	
?>
<table width="100%"  cellpadding="0" cellspacing="5" height="300">
<tr>
	

	<td valign="top">
		<strong>Customer Service</strong> <br>
			<table width="100%" class="solidborder">
				<tr style="background-image: url(images/tbl_th.png);color:#FFFFFF" align="center" height="20">
					<td width="2%">No</td><td width="33%">Title </td><td width="34%">Contents</td><td width="4%">Row</td><td width="27%">Action</td>
				</tr>
				<? if(mysql_num_rows($get_news)==0){ ?>
				<tr valign="top">
					<td align="center" colspan="7">
					- No record found - 
					</td>
				
				<? 
					}
					else
					{
						$no=1;
						while($a=mysql_fetch_array($get_news,MYSQL_ASSOC))
						{
							$id=$a['id'];
							if($no%2==0)
							{
								$bgcolor="#e5e5e5";
							}
							else
							{
								$bgcolor="#eeeeee";	
							}				
				?>
			  <tr height="20" valign="top" bgcolor="<?= $bgcolor ?>" onmouseover="this.style.backgroundColor='ccccff'" onmouseout="this.style.backgroundColor='<?= $bgcolor ?>'">
						<td align="center"><?= $no ?></td>
						<td>
						<?= $a['cat_name'] ?>
						
						</td>
						
						<td>
						<?
							$get_content=mysql_query("select * from os_custserv_content where cat_id=$id order by order_id asc")or die(mysql_error());
							
							if(mysql_num_rows($get_content)==0)
							{
						?>
						No record
						<? }else{ 
							while($c=mysql_fetch_array($get_content,MYSQL_ASSOC))
							{
						?>
						<a href="custserv_edit.php?id=<?= $c['id'] ?>"><?= $c['title'] ?></a><br>
						<? 
							} 
							}	
						?>
						
						</td>
						<td><?= $a['row'] ?></td>
						<td align="center">
						<a href="custserv_add.php?id=<?= $id ?>">Add Content</a> | <a href="custservcat_edit.php?id=<?= $id ?>">Edit</a> | <a href="custservcat_delete.php?id=<?= $id ?>">Delete</a></td>								
			  </tr>
				<? 
					$no++; 
						}
					}
				?>
				
			</table>
			
		<table>
			<form method="post" action="<?= $_SERVER['PHP_SELF'] ?>">
			<?
				$get_setting=mysql_query("select custserv_rows from os_setting where id=1");
			?>
			<tr>
				<td colspan="3">
				Total rows <input type="text" value="<?= mysql_result($get_setting,0,"custserv_rows") ?>" class="text" size="2" maxlength="1" name="total_rows">
				
				<input type="submit" value="Update" class="button" name="btnupdaterows">
				<br>
				</td>
			</tr>
			</form>
			<tr>
				<td colspan="3"><input type="button" value="Add New Title" class="button" onClick="window.open('custservcat_add.php','_self')"></td>
			</tr>
		</table>
		
		
		</td>
	</tr>
	
	
</table>
<? require("required/footer.php"); ?>

